using SalesPages.DomainModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;


namespace SalesPages.EntityFrameworkRepository.Mapping
{
    public class SurveyMap : EntityTypeConfiguration<Survey>
    {
        public SurveyMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Survey_id, t.SiteVersion });

            // Properties
            this.Property(t => t.Survey_id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.SiteVersion)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.SurveyName)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.SurveyContent)
                .IsRequired();

            this.Property(t => t.InsertBy)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.UpdateBy)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("Survey");
            this.Property(t => t.Survey_id).HasColumnName("Survey_id");
            this.Property(t => t.SiteVersion).HasColumnName("SiteVersion");
            this.Property(t => t.SurveyName).HasColumnName("SurveyName");
            this.Property(t => t.SurveyContent).HasColumnName("SurveyContent");
            this.Property(t => t.IsDevelopment).HasColumnName("IsDevelopment");
            this.Property(t => t.IsDeprecated).HasColumnName("IsDeprecated");
            this.Property(t => t.InsertBy).HasColumnName("InsertBy");
            this.Property(t => t.InsertDate).HasColumnName("InsertDate");
            this.Property(t => t.UpdateBy).HasColumnName("UpdateBy");
            this.Property(t => t.UpdateDate).HasColumnName("UpdateDate");
        }
    }
}
